import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'

Vue.use(VueRouter)

  const routes = [
    // 主页
    {
      path: '/',
      name: 'Home',
      component: Home,
      meta:{
        isshow:true
      }
    },
    // 分类
    {
      path: '/about',
      name: 'About',
      component: () => import( '../views/About.vue'),
      meta:{
        isshow:true
      }
    },
    // 购物车
    {
      path: '/cart',
      name: 'Cart',
      component: () => import( '../views/Cart.vue'),
      meta:{
        isshow:true
      }
    },
    //我得
    {
      path: '/mine',
      name: 'Mine',
      component: () => import( '../views/Mine.vue'),
      meta:{
        isshow:true
      }
    },
    // 状态页
    {
      path: '/details',
      name: 'Details',
      component: () => import('../views/Detailspag/Details.vue'),
      meta:{
        isshow:false
      },
      beforeEnter (to, from, next) {
        let isnum=JSON.parse(localStorage.getItem("islogin"))||false
        if(isnum){
          next()
        }else{
          next({
            name:'Login',
            params:{
              from:from
            }
          })
        }
      }
    },
    // 砍价列表页
    {
      path: '/regatearlist',
      name: 'Regatearlist',
      component: () => import( '../views/Shoplistpag/Regatearlist.vue'),
      meta:{
        isshow:false
      }
    },
    // 砍价详情页
    {
      path: '/bargindetails',
      name: 'Bargindetails',
      component: () => import( '../components/homecommon/Regatearpag/Bargindetails.vue'),
      meta:{
        isshow:false
      }
    },
    // 推荐列表页
    {
      path: '/calentura',
      name: 'Calentura',
      component: () => import( '../views/Shoplistpag/Calenturalist.vue'),
      meta:{
        isshow:false
      }
    },
    // 商品详情页
    {
      path:'/detalle',
      name:'Detalle',
      component: () => import( '../views/Detalle.vue'),
      meta:{
        isshow:false
      }
    },
    {
      path:'/selecttop',
      name:'Selecttop',
      component: () => import( '../views/Shoplistpag/SelectedTop.vue'),
      meta:{
        isshow:false
      }
    }
  ]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
